﻿<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <variable name="logDirectory" value="${basedir}/logs/${shortdate}"/>
    <nlog  internalLogFile="${logDirectory}nlogerrors.config" />
    <targets>
        <target name="mail1" xsi:type="Mail" smtpServer="smtpout.secureserver.net"
               from="tal@designpatterns.co.il" to="talg@netvision.net.il"
               subject="Error on design patterns site" smtpPassword="" smtpUsername=""/>

        <target name="mail" xsi:type="Mail" smtpServer=""
       from="tal@netvision.net.il" to="talg@netvision.net.il"
       subject="Error on design patterns site" smtpPassword="" smtpUsername=""/>


        <target name="database" xsi:type="DataBase">
            <dbprovider>
                mssql
            </dbprovider>
            <connectionstring>
                Data Source=talgiladi-pc\sqlexpress;Initial Catalog=ImagesDB;Integrated Security=True;
            </connectionstring>
            <!-- database connection parameters -->
            <!-- alternatively you could provide a single 'connectionstring' parameter -->

            <commandText>
                insert into Errors(TimeStamp,Message,StackTrace,Url,QueryString) values(@TimeStamp, @Message, @StackTrace,@Url,@QueryString)
            </commandText>
            <parameter name="@TimeStamp" layout="${date}"/>
            <parameter name="@Message" layout="${message}" size="255"/>
            <parameter name="@StackTrace" layout="${stacktrace}"/>
            <parameter name="@Url" layout="${aspnet-request:serverVariable=path_info}"/>
            <parameter name="@QueryString" layout="${aspnet-request:serverVariable=query_string}"/>


        </target>
        <target name="infoFile"  Encoding="utf-8"  xsi:type="File" fileName="${logDirectory}info.config"
        layout="${longdate} ${aspnet-request:serverVariable=path_info} ${aspnet-request:serverVariable=query_string} ${stacktrace} ${message}"/>

        <target name="traceFile" xsi:type="AsyncWrapper" queueLimit="5000"
            overflowAction="Discard">
            <target xsi:type="File" Encoding="utf-8"  fileName="${logDirectory}trace.config" layout="${longdate} ${aspnet-request:serverVariable=path_info} ${aspnet-request:serverVariable=query_string} ${stacktrace} ${message}"/>
            </target>

        <target name="errorsFile"  Encoding="utf-8"  xsi:type="File"  fileName="${logDirectory}errors.config"
       layout="${longdate} ${aspnet-request:serverVariable=path_info} ${aspnet-request:serverVariable=query_string} ${stacktrace} ${message}"/>

    </targets>
    <rules>
        <logger name="*" minlevel="Info" maxlevel="Info" writeTo="infoFile"/>
        <logger name="*" minlevel="Trace" maxlevel="Trace" writeTo="traceFile"/>
        <logger name="*" minlevel="Warn" maxlevel="Error" writeTo="database,errorsFile,mail"></logger>
    </rules>
</nlog>